a82fac
@@ -94,12 +94,8 @@
public class JettyContentExchange extends ContentExchange {
     @Override
     protected void onRequestComplete() throws IOException {
         LOG.trace("onRequestComplete");
-
-        // close the input stream when its not needed anymore
-        InputStream is = getRequestContentSource();
-        if (is != null) {
-            IOHelper.close(is, "RequestContentSource", LOG);
-        }
+        
+        closeRequestContentSource();
     }
 
     @Override
@@ -120,6 +116,8 @@
public class JettyContentExchange extends ContentExchange {
         try {
             super.onExpire();
         } finally {
+            // need to close the request input stream
+            closeRequestContentSource();
             doTaskCompleted();
         }
     }
@@ -131,6 +129,8 @@
public class JettyContentExchange extends ContentExchange {
         try {
             super.onException(ex);
         } finally {
+            // need to close the request input stream
+            closeRequestContentSource();
             doTaskCompleted(ex);
         }
     }
@@ -142,6 +142,8 @@
public class JettyContentExchange extends ContentExchange {
         try {
             super.onConnectionFailed(ex);
         } finally {
+            // need to close the request input stream
+            closeRequestContentSource();
             doTaskCompleted(ex);
         }
     }
@@ -159,6 +161,14 @@
public class JettyContentExchange extends ContentExchange {
         String params = getRequestFields().getStringField(HttpHeaders.CONTENT_ENCODING);
         return getScheme() + "//" + getAddress().toString() + getRequestURI() + (params != null ? "?" + params : "");
     }
+    
+    protected void closeRequestContentSource() {
+        // close the input stream when its not needed anymore
+        InputStream is = getRequestContentSource();
+        if (is != null) {
+            IOHelper.close(is, "RequestContentSource", LOG);
+        }
+    }
 
     protected void doTaskCompleted() {
         // make sure to lower the latch
